Python/MCQ on Python String Set 1 Sample Test,Sample questions

Question:
 Following is an example of ___________________
sv = “csiplearninghub.com”

1.List

2.String

3.Dictionary

4.None of the above

Posted Date:-2021-12-11 14:38:56


Question:
 Python allows _____________ operations on string data type.

1.Concatenation

2.Membership

3.Slicing

4.Slicing

Posted Date:-2021-12-11 18:52:47


Question:
 str[5 : 11] will return ___________ character

1.5

2.6

3.11

4.None of the above

Posted Date:-2021-12-11 19:02:27


Question:
 What is the index value of ‘i’ in string “Learning”

1.5

2.3

3.6

4.7

Posted Date:-2021-12-11 14:46:20


Question:
 What type of error is returned by the following :
str = "Learning"
print(str[10])

1.Error in Index

2.Index out of range in string

3.IndexError

4.None of the above

Posted Date:-2021-12-11 14:47:48


Question:
 What we call the following:


	

1.Escape Sequence

2.Special Character

3.Don’t have any common term

4.Keyword

Posted Date:-2021-12-11 14:45:02


Question:
 Which operator is used for string concatenation?

1.*

2.//

3.+

4.-

Posted Date:-2021-12-11 17:38:43


Question:
 Write the output of the following :
>>> str1 = 'Hello World! Hello Hello'
>>> str1.count('Hello')

1.1

2.2

3.3

4.4

Posted Date:-2021-12-11 19:22:56


Question:
 Write the output of the following code :
a = '''A
B
C'''
print(a)

1.ABC

2.A BC

3. A B C

4.Error

Posted Date:-2021-12-11 14:45:57


Question:
 Write the output of the following code :
a="Learn"
while(a):
    print(a)

1.L e a r n

2.Error

3.Infinite Loop

4.Learn

Posted Date:-2021-12-11 14:53:23


Question:
 Write the output of the following code :
for i in "STR":
     print(i)

1. S TR

2.STR

3.S T R

4.S T R

Posted Date:-2021-12-11 14:52:26


Question:
 Write the output of the following.
s = “hello 123”
print(s.islower())

1.False

2.True

3.Error

4.None of the above

Posted Date:-2021-12-11 19:19:25


Question:
 Write the output of the following:
print('aisabisacisadisae'.split('isa',3))

1.[‘a’, ‘b’, ‘c’, ‘disae’]

2.[‘a’, ‘b’, ‘cisadisae’]

3. [‘a’, ‘b’, ‘c’, ‘d’, ‘e’]

4.None of the above

Posted Date:-2021-12-11 19:51:59


Question:
>>> “Hey!”.endswith(‘!’) will return ______

1.True

2.False

3.Error

4.None of the above

Posted Date:-2021-12-11 19:28:26


Question:
A _____________ can be created by enclosing one or more characters in single, double or triple quote

1. String

2.List

3.Tuple

4.Dictionary

Posted Date:-2021-12-11 18:43:15


Question:
Characters in a string can be _________ enclosed in quotes.

1.Digits

2.white space

3.letter

4.All the above

Posted Date:-2021-12-11 18:44:07


Question:
Content of string can not be changed, it means that string is

1.mutable

2.immutable

3.reversible

4.None of the above

Posted Date:-2021-12-11 18:50:05


Question:
Each individual character in a string can be accessed using a technique called _____

1.Indexing

2.Replication

3.Concatenation

4.None of the above

Posted Date:-2021-12-11 18:45:12


Question:
find( ) function returns ___________ if the substring is not present in the given string

1.0

2.1

3.-1

4.Error

Posted Date:-2021-12-11 19:26:52


Question:
Following code will return ?
s = “Hello”
print(s.count(‘l’,2,5))

1.2

2.3

3.1

4.None of the above

Posted Date:-2021-12-11 19:15:34


Question:
How many operators are used in the following statement?
7 + 4 * 8 // 2 ** 2 - 6 / 1

1.5

2.6

3.7

4.8

Posted Date:-2021-12-11 17:40:42


Question:
If no delimiter is given in split( ) function then words are separated by ____

1.space

2.colon

3.semi colon

4.None of the above

Posted Date:-2021-12-11 19:41:57


Question:
If we give index value out of the range then we get an ___

1.ValueError

2. SyntaxError

3. IndexError

4.Error

Posted Date:-2021-12-11 18:46:06


Question:
Index value in String should be of type ________________

1.Float

2.Integer

3.String

4.Boolean

Posted Date:-2021-12-11 14:47:08


Question:
index( ) function returns _______________ if the substring is not present in the given string

1.0

2.1

3.-1

4.Error

Posted Date:-2021-12-11 19:27:39


Question:
Name a function which is same as find() but raises an exception if the substring is not present in the given string.

1. index( )

2.endswith( )

3. startswith( )

4.count( )

Posted Date:-2021-12-11 19:17:06


Question:
Name the function which is used to find length of string.

1.length( )

2.len( )

3. strlen( )

4.slen( )

Posted Date:-2021-12-11 14:51:37


Question:
partition( ) function of string in python return the result in the form of ____

1.String

2.List

3.Tuple

4.Dictionary

Posted Date:-2021-12-11 19:39:31


Question:
partition() function divides the main string into ________ substring.

1.1

2.2

3.3

4.4

Posted Date:-2021-12-11 19:40:24


Question:
print(“aNd&*”.swapcase()) will display _

1.AnD*&

2.AnD&*

3. aNd&*

4.Error

Posted Date:-2021-12-11 19:53:58


Question:
Slice operation can also take a third parameter that specifies the _____

1. Starting index

2.Ending index

3.Step Size

4.None of the above

Posted Date:-2021-12-11 19:08:24


Question:
split( ) function returns the _______________of words delimited by the specified substring.

1.List

2.Tuple

3.Dictionary

4.None of the above

Posted Date:-2021-12-11 19:41:17


Question:
str[11 : 5] will return _________

1.empty string

2.complete string

3. string of six characters

4.None of the above

Posted Date:-2021-12-11 19:04:24


Question:
The index of the first character ____________ on the string is 0

1. from left

2.from right

3.from middle

4.None of the above

Posted Date:-2021-12-11 18:46:58


Question:
We can access each character of a string or traverse a string using ___

1.for loop only

2.while loop only

3.both of the above

4.conditional statement

Posted Date:-2021-12-11 19:11:29


Question:
What index value is returned by the following code?
s = “Hello”
print(s.find(‘l’))

1.2

2.3

3.4

4.-2

Posted Date:-2021-12-11 19:14:39


Question:
What type of error is returned by statement :
>>> str[1.5]

1.SyntaxError

2.ValueError

3.. IndexErro

4.. TypeError

Posted Date:-2021-12-11 18:47:49


Question:
Which character will have same index value when you access elements from the beginning and from the end(ignore the negative sign) in the following string.
s = “Welcome to my blog”

1.‘t’

2.‘ ‘

3. ‘o’

4. ‘t’

Posted Date:-2021-12-11 14:48:47


Question:
Which function in the following statement will execute first?
print("amit".lower().upper())

1. print( )

2. lower( )

3. upper( )

4.None of the above

Posted Date:-2021-12-11 19:49:14


Question:
Which function in the following statement will execute last?
print("amit".lower().upper())

1.print( )

2.lower( )

3.upper( )

4.None of the above

Posted Date:-2021-12-11 19:50:49


Question:
Which of the following function can take maximum three arguments/parameters?

1.find( )

2.index( )

3.count( )

4.All the above

Posted Date:-2021-12-11 19:46:36


Question:
Which of the following function removes only leading spaces from the string?

1.strip( )

2.lstrip( )

3. rstrip( )

4.Lstrip( )

Posted Date:-2021-12-11 19:45:53


Question:
Which of the following function return the integer value?

1.lower( )

2. upper( )

3.islower( )

4.find( )

Posted Date:-2021-12-11 19:47:32


Question:
Which of the following function returns the ASCII/Unicode value character?

1.asc( )

2.ord( )

3.asci( )

4. ascii( )

Posted Date:-2021-12-11 18:39:05


Question:
Which of the following function returns the index value of first occurrence of substring occurring in the given string.

1. index( )

2.. find( )

3.Both of the above

4.None of the above

Posted Date:-2021-12-11 19:26:08


Question:
Which of the following function returns the string with first letter of every word in the string in uppercase and rest in lowercase?

1.swapcase( )

2.upper( )

3.title( )

4.capitalize( )

Posted Date:-2021-12-11 19:13:15


Question:
Which of the following function returns True if the string is non-empty and has all uppercase alphabets.

1. islower( )

2. islower( )

3.Islower( )

4. islower( )

Posted Date:-2021-12-11 19:35:41


Question:
Which of the following is a mapping data type?

1.String

2.List

3.Tuple

4.Dictionary

Posted Date:-2021-12-11 18:41:51


Question:
Which of the following is correct slicing operation to extract every kth character from the string str1 starting from n and ending at m-1.

1.str1[: : k]

2.str1[n : m+1 : k]

3.str1[n : m : k ]

4.str1[m : n : k ]

Posted Date:-2021-12-11 19:10:01


Question:
Which of the following is not a String built in functions?

1. partition( )

2.isupper( )

3.lower( )

4.swapcases( )

Posted Date:-2021-12-11 17:49:45


Question:
Which of the following is not an inbuilt function of string?

1.length( )

2.find( )

3. endswith( )

4.split( )

Posted Date:-2021-12-11 19:48:27


Question:
Which of the following statement is correct in accessing each element of string?a)
a="Learning"
while(i):
   print(i)

b)
a="Learning"
for i in a:
   print(i)

1. a only

2.b only

3.both a and b

4.None of the above

Posted Date:-2021-12-11 14:49:36


Question:
Which of the following statements will also return the same result as given statement? print(“Computer” + “Computer”)

1.print(“Computer” , ” “, “Computer”)

2.print(“Computer”,”Computer”)

3.print(“Computer” **2)

4.print(“Computer” * 2)

Posted Date:-2021-12-11 18:40:05


Question:
Which of the following will return reverse string str1?

1.str1[ : : -1]

2.str1[: : 1]

3.str1[: -1 : -1 ]

4.None of the above

Posted Date:-2021-12-11 19:10:34


Question:
Which of the function returns Boolean value?

1. find( )

2.index( )

3.endwith( )

4.endswith( )

Posted Date:-2021-12-11 19:29:14


Question:
Which operator is used with integers as well as with strings?

1./

2.//

3.**

4.*

Posted Date:-2021-12-11 14:54:15


Question:
Write the output of the following :
>>> str1 = 'Hello World! Hello Hello'
>>> str1.count('Hello',12,25)

1.1

2.2

3.3

4.4

Posted Date:-2021-12-11 19:22:20


Question:
Write the output of the following :
>>> str1 = ‘HelloWorld!!’
>>> str1.isalnum()

1.False

2.True

3.Error

4.None of the above

Posted Date:-2021-12-11 19:21:46


Question:
Write the output of the following :
print("Absbcbcgdbc".count("b",4))

1.1

2.2

3.3

4.4

Posted Date:-2021-12-11 19:23:31


Question:
Write the output of the following :
print("Absbcbcgdbc".find("b",5))

1.1

2.2

3.5

4.6

Posted Date:-2021-12-11 19:23:58


Question:
Write the output of the following code :
a= "Welcome to 
blog"
print(a)

1.Welcome to blog

2.Welcome to blog

3.Welcome to blog

4.Error

Posted Date:-2021-12-11 14:42:52


Question:
Write the output of the following code :
a= "Welcome to "my" blog"
print(a)

1.Welcome to “my” blog

2.Welcome to ”my” blog

3.Error

4.None of the above

Posted Date:-2021-12-11 14:42:08


Question:
Write the output of the following code :
for i in (1,2,3):
    print("@" * i)

1.Error

2.@@@@@@

3.@ @@ @@@

4.@ @ @ @ @ @

Posted Date:-2021-12-11 17:39:51


Question:
Write the output of the following code :
s= "str"
s1 = "string"
print(s1 in s)

1.True

2.False

3.Error

4.None of the above

Posted Date:-2021-12-11 17:42:48


Question:
Write the output of the following code :
s= "str"
Write the output of the following code :
for i in range(65,70):
     print(chr(i))

1.Error

2.TypeError

3.A B C D E

4.ABCDE

Posted Date:-2021-12-11 17:45:04


Question:
Write the output of the following code :
s= "str"
Write the output of the following code :
for i in range(65,70):
     print(chr(i))

1.Error

2.TypeError

3.A B C D E

4.ABCDE

Posted Date:-2021-12-11 17:45:11


Question:
Write the output of the following code :
s="blog"
for i in range(-1,-len(s),-1):
     print(s[i],end="$")

1.g$o$l$b$

2.g$o$l$

3.Error

4.None of the above

Posted Date:-2021-12-11 17:42:03


Question:
Write the output of the following code :
str = "Welcome"
l=len(str)
print(l)

1.6

2.7

3.8

4.Error

Posted Date:-2021-12-11 14:44:05


Question:
Write the output of the following code :
str = "Welcome"
str[2] = 'a'
print(str)

1. Weacome

2.Error

3. aWelcome

4.Welcomea

Posted Date:-2021-12-11 14:43:34


Question:
Write the output of the following.
>>> str1 = ‘Hello World! Hello
>>> str1.index(‘Hee’)

1.0

2.1

3.Error

4.None of the above

Posted Date:-2021-12-11 19:17:35


Question:
Write the output of the following.
>>> str1 = ‘Hello World!’
>>> str1.endswith(‘World!’)

1.True

2.False

3.yes

4.Error

Posted Date:-2021-12-11 19:18:35


Question:
Write the output of the following.
a = "Blog"
a ='a'
print(a)

1.Bloga

2.aBlog

3.Blog

4.a

Posted Date:-2021-12-11 14:40:01


Question:
Write the output of the following.
print(‘#’.join(“12345”))

1.#12345

2.#12345#

3.1#2#3#4#5

4.1#2#3#4#5#

Posted Date:-2021-12-11 17:48:44


Question:
Write the output of the following.
str = “python”
print(str[2+1])

1. t

2.h

3.th

4.Error

Posted Date:-2021-12-11 18:48:35


Question:
Write the output of the following:
>>> len(" python".lstrip()) #2 spaces are given before "python"

1.5

2.6

3.7

4.8

Posted Date:-2021-12-11 19:44:42


Question:
Write the output of the following:
>>> str1 = 'hello ??'
>>> str1.islower( )

1.NO

2.True

3.false

4.Error

Posted Date:-2021-12-11 19:32:45


Question:
Write the output of the following:
>>> str1 = 'Hello World!'
>>> str1.replace('o' , '*')

1.Hello World!’

2. ‘Hell* W*rld!’

3.‘Hello W*rld!’

4.Error

Posted Date:-2021-12-11 19:37:00


Question:
Write the output of the following:
>>> str1 = 'hello WORLD!'
>>> str1.title()

1. HELLO world

2.Hello World

3.Hello world

4.HeLlO WoRlD

Posted Date:-2021-12-11 19:21:04


Question:
Write the output of the following:
>>> str1 = 'India is a Great is Country'
>>> str1.partition('is')

1.(‘India ‘, ‘is’, ‘ a Great is Country’)

2.(‘India ‘, ‘is’, ‘a Great’, ‘is’, ‘Country’)

3.(‘India ‘, ‘is’, ‘ a Great Country’)

4.Error

Posted Date:-2021-12-11 19:37:39


Question:
Write the output of the following:
>>> str1 = 'String MCQ'
>>> str1.startswith('Str')

1.True

2.False

3.yes

4.No

Posted Date:-2021-12-11 19:29:59


Question:
Write the output of the following:
"@".join("python")

1.p@y@t@h@o@n’

2.‘p@y@t@h@o@n@’

3.@p@y@t@h@o@n@’

4.‘@

Posted Date:-2021-12-11 19:44:10


Question:
Write the output of the following:
"python".join("@")

1.‘p@y@t@h@o@n’

2.p@y@t@h@o@n@’

3.‘@p@y@t@h@o@n@’

4.@’

Posted Date:-2021-12-11 19:43:13


Question:
Write the output of the following:
2 + '3'

1. 2 3

2.23

3.SyntaxError

4.TypeError

Posted Date:-2021-12-11 17:37:35


Question:
Write the output of the following:
a="We
to my 
b	 ok"
print(a)

1.We to my b ok

2.We to myb ok

3.Weto my b ok

4.None of the above

Posted Date:-2021-12-11 14:41:21


Question:
Write the output of the following:
for i in range(len("python"),12,2):
      print("python"[i-6])

1.p t o

2.p y t h o n

3.y h n

4.p y t h

Posted Date:-2021-12-11 18:41:04


Question:
Write the output of the following:
print('aisabisacisadisae'.split('isa'))

1.[‘a’, ‘b’, ‘c’, ‘disae’]

2.[‘a’, ‘b’, ‘cisadisae’]

3.[‘a’, ‘b’, ‘c’, ‘d’, ‘e’]

4.None of the above

Posted Date:-2021-12-11 19:52:49


Question:
Write the output of the following:
print("Welcome-Python".isalnum())

1.True

2.False

3.yes

4.No

Posted Date:-2021-12-11 19:30:30


Question:
Write the output of the following:
print(“A#B#C#D#E”.replace(“#”,”?”))

1.A#B#C#D#E

2.A?B?C?D?E

3.Can not replace as Strings are immutable

4.Error

Posted Date:-2021-12-11 17:46:53


Question:
Write the output of the following:
print(“A#B#C#D#E”.split(“#”,2))

1.[‘A’, ‘B’, ‘C#D#E’]

2.[‘A#’, ‘B#’, ‘C#D#E’]

3. [‘A’, ‘B’, ‘C’ , ‘D’ , ‘E’]

4.Error

Posted Date:-2021-12-11 17:46:04


Question:
Write the output of the following:
print(“I love my Country”.find(“o”,4))

1.3

2.12

3.11

4.3,11

Posted Date:-2021-12-11 17:47:54


Question:
Write the output of the following:
print(len("\\\///"))

1.9

2.Error

3.3

4.6

Posted Date:-2021-12-11 18:37:53


Question:
Write the output of the following:
print(str("WelcomePython".isalnum()).upper())

1.TRUE

2.True

3.FLAS

4.Error

Posted Date:-2021-12-11 19:31:29


Question:
Write the output of the following:
s = ” Hello”
print(s.find(‘a’))

1. 0

2.-1

3.1

4.Error

Posted Date:-2021-12-11 19:14:02


Question:
Write the output of the following:
str = "Amit is a is a"
s = str.partition('is')
print(s[1])

1. is a

2.a

3.is

4.i

Posted Date:-2021-12-11 19:38:44


Question:
_________ method is used to access some part of a string or substring.>>> str1 = ‘Hello World!’ >>> ‘W’ in str1

1.Slicer

2.Slicing

3.Membership

4.None of the above

Posted Date:-2021-12-11 18:58:22


More MCQS

  1. Python MCQS - Function
  2. Python MCQS - GUI in python
  3. Python MCQS - Operators
  4. Python MCQS - Data type in python
  5. Python MCQS - loops in python
  6. Python MCQS - Numpy
  7. Python MCQS - sqlite3
  8. Python MCQS - Library
  9. Python MCQS - Pandas
  10. Python MCQs
  11. Dictionary Python MCQ set 1
  12. Dictionary Python MCQ set 2
  13. MCQ For Python Fundamentals
  14. MCQ Introduction to Python Section 1
  15. MCQ Introduction to Python Section 2
  16. MCQ Introduction to Python Section 3
  17. MCQ on Flow of Control in Python Set 1
  18. MCQ on Flow of Control in Python Set 2
  19. MCQ on Python String Set 1
  20. File Handling in Python section 1
  21. File Handling in Python section 2
  22. Python Functions MCQS Set 1
  23. Python Functions MCQS Set 2
  24. MCQ on List in Python
  25. Pandas MCQ Questions Set 1
  26. Pandas MCQ Questions Set 2
  27. Tuple MCQ in Python
  28. Python dataframe MCQ
  29. Python Mcq Set 1
  30. Python Mcq Set 2
  31. Python Mcq Set 3
  32. Python Mcq Set 4
  33. Python Mcq Set 5
  34. Python Mcq Set 6
  35. Python Mcq Set 7
  36. Python Mcq Set 8
  37. Python Mcq Set 9
  38. Python Mcq Set 10
  39. Python Mcq Set 11
  40. Python Mcq Set 12
  41. Python Mcq Set 13
  42. Python Mcq Set 14
  43. Python Mcq Set 15
  44. Python Mcq Set 16
  45. Python Mcq Set 17
  46. Python Mcq Set 18
  47. Python Mcq Set 19
  48. Python Mcq Set 20
  49. Python Mcq Set 21
  50. Python MCQ
  51. Python MCQ Questions with Answer
  52. Test
  53. python mcq question and answer
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!